package com.ssm.controller;

import com.ssm.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2016/6/29.
 */

@Controller
public class TestController {

    @Autowired
    private TestService testService;


    @RequestMapping( "/test")
    public/* @ResponseBody */Object test() throws Exception {
        System.out.println();

        List<Map<String, Object>> list = new ArrayList<>();


        Map<String,Object> map = new HashMap<>();
        map.put("id",15);
        map.put("rrrr","dfsa");
        list.add(map);
        Map<String,Object> map1 = new HashMap<>();
        map1.put("id",113);
        map1.put("rrrr","dfs---a");
        list.add(map1);
        System.out.println(testService.addAll(map));

        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("list",testService.findAll());
        modelAndView.setViewName("test/test");
        return new HashMap(){{this.put("a","a");}};
    }

}
